﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DDD4Fun.Common
{
    public class CList
    {
        public static void TestList()
        {

            CListV2 l2 = new CListV2()
            {
                new CPerson(){ FirstName = "1"},
                new CPerson(){ FirstName = "2"}
            };
            IList<CPerson> il2 = l2;
            il2.Add(new CPerson() { FirstName = "3" });
            foreach (var p in il2)
            {
                Console.WriteLine(p.FirstName);
            }

        }
    }


    public class CListV1 : IEnumerable<CPerson>, ICollection<CPerson>
    {
        #region IEnumerable<CPerson> Members

        public IEnumerator<CPerson> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region ICollection<CPerson> Members

        public void Add(CPerson item)
        {
            throw new NotImplementedException();
        }

        public void Clear()
        {
            throw new NotImplementedException();
        }

        public bool Contains(CPerson item)
        {
            throw new NotImplementedException();
        }

        public void CopyTo(CPerson[] array, int arrayIndex)
        {
            throw new NotImplementedException();
        }

        public int Count
        {
            get { throw new NotImplementedException(); }
        }

        public bool IsReadOnly
        {
            get { throw new NotImplementedException(); }
        }

        public bool Remove(CPerson item)
        {
            throw new NotImplementedException();
        }

        #endregion

        public CPerson this[int i]
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }
    }

    public class CListV2 : List<CPerson>
    {
        public new void Add(CPerson item)
        {
            item.FirstName += "changed";
            base.Add(item);
        }
    }

    public class CPerson
    {
        public string IDCode { set; get; }

        public string FirstName { set; get; }

        public string LastName { set; get; }
    }
}
